<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./http.js"></script>
</head>
<body>
    <h1>登录</h1>
    <p>
        账号：<input type="text"id="" placeholder="请输入十一位的手机号">
    </p>
    <p>
        密码：<input type="password"id="" placeholder="请输入六位密码">
    </p>
    <button>立即登录</button>
    <script>
                let btn = document.querySelector('button');
        let tell = document.querySelector('#tell');
        let pwd = document.querySelector('#pwd');
        btn.addEventListener('click',function(){
            if(tell.value && pwd.value){
                let reg = /^1[3-9][0-9]{9}$/;
                if(reg.test(tell.value)){
                    let data = {
                        account:tell.value,
                        password:pwd.value
                    }
                    http.post('http://139.9.177.51:8099/users/login',data,function(res){
                        if(res.status ==0){
                            alert('登陆成功')
                        }else{
                            alert('登录失败')
                        }
                    })
                }else{
                    alert('手机号不正确')
                }
            }else{
                alert('信息不完整')
            }
        })
    </script>
</body>
</html>